Ext.onReady(function(){
	
	areaNotFindSalesiswriteidb= Ext.get('areaNotFindSalesiswriteid').getValue()==1?true:false;
	var areaNotFindSalesMoblieField=new Ext.form.TextField({
		fieldLabel:'手机号',
		width:120,
		labelAlign:'right'
	});
	var areaNotFindSalesCenterField=new Ext.form.TextField({
		fieldLabel:'短信中心号',
		width:120,
		labelAlign:'right'
	});
	var areaNotFindSalesBeginTimeField=new Ext.form.DateField({
		fieldLabel:'起止时间',
		value:new Date(),
		width:120
	});
	
	var areaNotFindSalesEndTimeField=new Ext.form.DateField({
		fieldLabel:'结束时间',
		value:new Date(),
		width:120
	});
	
	var areaNotFindSalesnType=new Ext.form.ComboBox({
		fieldLabel:'查询条件',
		width:100,
		store:new Ext.data.ArrayStore({
			fields:['value','text'],
			data:[
				[1,'按公司'],
				[2,'按CP']
			]
		}),
		mode:'local',
		valueField:'value',
		displayField:'text',
		value:1,
		editable:false,
		triggerAction:'all'
	})
	
	var areaNotFindSalesSearchBtn=new Ext.Button({
		text:'查询',
		handler:function(){
			areaNotFindSalesGridStore.load({
				params : {
					start : 0,
					limit : 20,
					'begintime':areaNotFindSalesBeginTimeField.getValue(),
					'endtime':areaNotFindSalesEndTimeField.getValue(),
					'sName':areaNotFindSalesCenterField.getValue(),
					'smobileNo':areaNotFindSalesMoblieField.getValue(),
					'nType':areaNotFindSalesnType.getValue()
				}
			});
		}
	});
	
	var areaNotFindSalesSearch=new Ext.Panel({
		height:69,
		region:'north',
		layout:'column',
		frame: true,
		border:false,
		bodyBorder:false,
		items:[
			{columnWidth:.3,layout:'form',labelAlign:'right',items:[areaNotFindSalesBeginTimeField,areaNotFindSalesMoblieField]},
			{columnWidth:.3,layout:'form',labelAlign:'right',items:[areaNotFindSalesEndTimeField,areaNotFindSalesCenterField]},
			{columnWidth:.2,layout:'form',labelAlign:'right',items:[areaNotFindSalesnType]},
			{columnWidth:.2,layout:'form',labelAlign:'right',items:[areaNotFindSalesSearchBtn]}
		]		
	});
	
	
	 areaNotFindSalesGridStore = new Ext.data.Store({
        autoLoad: false,
        proxy : new Ext.data.HttpProxy({
            url: 'searchAreaNotFindSales.do'
        }),
        baseParams:{'begintime':areaNotFindSalesBeginTimeField.getValue(),
					'endtime':areaNotFindSalesEndTimeField.getValue(),
					'sName':areaNotFindSalesCenterField.getValue(),
					'smobileNo':areaNotFindSalesMoblieField.getValue(),
					'nType':areaNotFindSalesnType.getValue()},
        reader:new Ext.data.JsonReader({
             totalProperty: 'totalSize',
             root:'list'
        },[
            {name: 'nserverGSMId',mapping:'nserverGSMId', type: 'int'},
        	{name: 'ssendMobileNo',mapping:'ssendMobileNo', type: 'string'},
        	{name: 'ssendIMSI',mapping:'ssendIMSI', type: 'string'},
        	{name: 'ssmscenterNo',mapping:'ssmscenterNo', type: 'string'},
        	{name: 'sclientId',mapping:'sclientId', type: 'int'},
        	{name: 'screatTime',mapping:'screatTime', type: 'string'}
        ])     
    });
    
    areaNotFindSalesGridStore.on("beforeload", function(thiz, options) {
		thiz.baseParams["smobileNo"] = areaNotFindSalesMoblieField.getValue(); 
		thiz.baseParams["begintime"] = areaNotFindSalesBeginTimeField.getValue();
		thiz.baseParams["endtime"] = areaNotFindSalesEndTimeField.getValue();
		thiz.baseParams["sName"] = areaNotFindSalesCenterField.getValue();
		thiz.baseParams["nType"] = areaNotFindSalesnType.getValue();
	});
    
	var areaNotFindSalesGridBar=new Ext.PagingToolbar({
		store: areaNotFindSalesGridStore,
		displayInfo: true,
		pageSize:20,
		displayMsg : '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
		emptyMsg: "没有记录可以显示",
		beforePageText:'当前页码',
		afterPageText:'共{0}页', 
		firstText:'第一页', 
		prevText:'上一页', 
		nextText:'下一页', 
		lastText:'最后一页', 
		refreshText:'刷新当前页',
		items:['-','仅显示没有归属地的销量记录']
     });
     
	areaNotFindSalesGrid = new Ext.grid.GridPanel({
        store: areaNotFindSalesGridStore,
        region:'center',
        bodyBorder:false,
        stripeRows:true,
		disableSelection: true,
		border:false,
		frame:true,
		loadMask :{msg:"数据加载中，请稍等..."},
		layout:'fit',
		viewConfig:{
			forceFit: true,
			scrollOffset:0
		},
        cm:new Ext.grid.ColumnModel([
        	new Ext.grid.RowNumberer(),
        	{header: "序号", flex: 1, dataIndex: 'nserverGSMId', sortable: true},
            {header: "手机号", flex: 1, dataIndex: 'ssendMobileNo', sortable: true},
            {header: "短信中心号",flex: 1, dataIndex: 'ssmscenterNo', sortable: true},
            {header: "客户ID", flex: 1, dataIndex: 'sclientId', sortable: true},
            {header: "时间",flex: 1, dataIndex: 'screatTime', sortable: true}
        ]),
        bbar: areaNotFindSalesGridBar
    });
    
	 var areaNotFindSalesMainPanel =new Ext.Viewport({
		layout:'border',
		renderTo:'areaNotFindSalesDIV',
		id:'areaNotFindSalesMainPanel',
		items:[areaNotFindSalesGrid,areaNotFindSalesSearch],
		listeners: {
	        'resize': function(viewport,adjWidth,adjHeight,rawWidth,rawHeight)  {
	          	Ext.getCmp("areaNotFindSalesMainPanel").setHeight((document.body.clientHeight - 290) * 0.67);  
			}
    	}
	});
});